<#include "../../common/_header.htm">
<div id="hidebox" style="height:100%;width:100%">
    <div class="box-body table-responsive">
        <!--<div style="display: flex;flex-direction: row-reverse;">
            <input type="button" class="btn btn-primary daobtn" onclick="exportDetailList();" value="导出" />
        </div>-->
        <table id="table" class="table text-nowrap"></table>
    </div>
</div>
<script>
    var dialog = top.dialog.get(window);
    var data = dialog.data; // 获取对话框传递过来的数据
    $(function() {
        /** 回去传值 **/
        $('#table').datagrid({
            toolbar: [{
                iconCls: 'icon-print',
                text:'导出Excel',
                handler: function(){
                    //下载
                    exportDetailList()
                }
            }],
            url: '${ctx}/phone/multipleData/phoneToBillDetail',
            method: 'post',
            queryParams:data,
            pageSize:30,
            pageList:[30,50,100,150,200],
            pageNumber:1,//当前页号,
            loadMsg:"正在加载，请稍后",//加载数据时的提示信息
            emptyMsg:"暂无信息",//加载数据为空时的信息
            height:($(window).height())-50,
            rownumbers:true,//序号
            fitColumns: true,//使表格自适应页面宽度
            pagination: true,//是否分页
            singleSelect: true,
            columns:[[ //每一列的具体设置。
                {field:'accountBody',title:'交易主体'},
                {field:'accountBodyNumber',title:'交易主体账号'},
                {field:'accountBodyCard',title:'交易主体卡号'},
                {field:'accountRival',title:'交易对手'},
                {field:'accountRivalNumber',title:'交易对手账号'},
                {field:'accountRivalCard',title:'交易对手卡号'},
                {field:'sign',title:'交易类型',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        return value==0?'流入':'流出'
                    }
                },
                {field:'tradeDate',title:'交易时间',sortable: true,
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        if(value){
                            var date = new Date(value);
                            return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
                        }else{
                            return '-';
                        }
                    }
                },
                {field:'accountMoney',title:'交易金额',sortable: true},
                {field:'surplusMoney',title:'交易后余额',sortable: true},
                {field:'contentAbstract',title:'摘要'},
                {field:'accountRivalBank',title:'对手归属行'},
                {field:'accountBodyBank',title:'主体归属行'},
                {field:'institutionNumber',title:'对方机构号'},
                {field:'tellerNumber',title:'柜员号'},
                {field:'remarks',title:'备注'}
            ]],
            onHeaderContextMenu: function(e, field){
                e.preventDefault();
                if (!cmenu){
                    createColumnMenu();
                }
                cmenu.menu('show', {
                    left:e.pageX,
                    top:e.pageY
                });
            }
        })
    });
    function exportDetailList(){
        let serviceUserInformation = data.serviceUserInformation;
        let idNumber = data.idNumber;
        let ct_beginTime=data.ct_beginTime;
        let ct_endTime=data.ct_endTime;
        let caseId=data.caseId;

        var xhr = new XMLHttpRequest();
        var url="${ctx}/phone/multipleData/down_phoneToBillDetail";
        xhr.open('POST', url, true);
        xhr.responseType = "blob";  // 返回类型blob
        // 定义请求完成的处理函数
        xhr.onload = function () {
            // 请求完成
            if (this.status === 200) {
                var content = this.response;
                var aTag = document.createElement('a');
                var blob = new Blob([content]);
                var headerName = xhr.getResponseHeader("Content-disposition");
                var fileName = decodeURIComponent(headerName).substring(20);
                aTag.download = fileName;
                aTag.href = URL.createObjectURL(blob);
                aTag.click();
                URL.revokeObjectURL(blob);
            }
        };
        // 发送ajax请求
        var formdata=new FormData();
        formdata.append("serviceUserInformation",serviceUserInformation);
        formdata.append("idNumber",idNumber);
        formdata.append("ct_beginTime",ct_beginTime);
        formdata.append("ct_endTime",ct_endTime);
        formdata.append("caseId",caseId);
        xhr.send(formdata);
    };
</script>
<style>
    #hidebox {
        top: 23px;
        left: 2%;
        border-radius: 5px;
        background-color:#fff;
        z-Index:9999;
        padding: 10px;
        overflow:hidden;
    }
    .box-body.table-responsive {
        height: 100%;
    }
</style>
</body>
</html>
